<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="js/vue.js" type="text/javascript" charset="utf-8"></script>
    <title>为图片设置边框</title>

</head>

<body>
    <div id="box">
        边框宽度: <input type="text" v-model="border">
        <p>
            <img width="200" src="img/line.jpg" v-set-border="border">
        </p>
    </div>
    <script>
        new Vue({
            el: '#box',
            data: {
                border: ''
            },
            directives: {
                setBorder: {
                    update: function(el, binding) {
                        el.border = binding.value; //指令绑定的值赋给el绑定的元素img，设置img元素的边框
                    }
                }
            }
        })
    </script>
</body>

</html>